﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Model;
using BLL;
using Utility;

public partial class Vehicle_Base_VehicleAdd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btn_Add_Click(object sender, EventArgs e)
    {
        Vehicle vehicle = new Vehicle();
        vehicle.FrameNO = txt_FrameNO.Text.Trim();
        vehicle.VehicleID = txt_VehicleID.Text.Trim();
        vehicle.VehicleType = int.Parse(ddl_Type.SelectedValue.ToString());
        vehicle.VehiclePrice = decimal.Parse(txt_Price.Text.Trim());
        vehicle.StartUseDate = DateTime.Parse(txt_StartDate.Text.Trim());
        vehicle.KeepPerson = txt_Keep.Text.Trim();
        vehicle.BackupKeyPerson = txt_BackupKey.Text.Trim();
        vehicle.ChargePerson = txt_ChargePerson.Text.Trim();
        vehicle.SuperChargePerson = txt_SuperCharge.Text.Trim();
        vehicle.PlanScrapDate = DateTime.Parse(txt_PlanDate.Text.Trim());
        vehicle.OrganID = int.Parse(ddl_Organ.SelectedValue.ToString());

        VehicleBLL vBLL = new VehicleBLL();
        int re = vBLL.Add(vehicle);
        if (re > 0)
        {
            UtilityService.Alert(this.Page, "成功");
            Response.Redirect("VehicleMgr.aspx");
        }
        else
        {
            UtilityService.Alert(this.Page, "失败");
        }
    }
    protected void VehicleSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
    {
        int re = (int)e.ReturnValue;
        if (re > 0)
        {
            UtilityService.Alert(this.Page, "添加成功!");
            Response.Redirect("VehicleMgr.aspx");
        }
        else
        {
            UtilityService.Alert(this.Page, "失败");
        }
    }
}
